package com.itheima.dao;

import com.itheima.domain.Customer;
import com.itheima.domain.User;
import com.itheima.domain.Visit;
import org.springframework.orm.hibernate5.support.HibernateDaoSupport;

import java.util.List;

/**
 * Created by Mr.King on 2017/2/26.
 */
public class VisitDao extends BaseDao<Visit> {
    public List<User> findUser() {
        List<User> list = (List<User>) this.getHibernateTemplate().find("from com.itheima.domain.User");
        return list;
    }

    public List<Customer> findCustomer() {
        List<Customer> list = (List<Customer>) this.getHibernateTemplate().find("from com.itheima.domain.Customer");
        return list;
    }

    public List<Visit> likeSerch(String uvid) {
        return (List<Visit>) this.getHibernateTemplate().find("from com.itheima.domain.Visit where uvid in ("+uvid+")");
    }

    public List<User> findUsers(Visit visit) {
        return (List<User>) this.getHibernateTemplate().find("from com.itheima.domain.User where username like ?","%"+visit.getUser().getUsername()+"%");
    }
}
